import request from '@/utils/request'

// 查询部门列表
export function listDomain(query) {
  return request({
    url: '/system/questiondomain/list',
    method: 'get',
    params: query
  })
}

// 查询部门列表（排除节点）
export function listDomainExcludeChild(domainId) {
  return request({
    url: '/system/questiondomain/list/exclude/' + domainId,
    method: 'get'
  })
}

// 查询部门详细
export function getDomain(domainId) {
  return request({
    url: '/system/questiondomain/' + domainId,
    method: 'get'
  })
}

// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: '/system/questiondomain/treeselect',
    method: 'get'
  })
}

export function treeselect2(companyId,naireId) {
  return request({
    url: '/system/questiondomain/treeselect2?companyId='+companyId+'&naireId='+naireId,
    method: 'get'
  })
}

// 查询部门下拉树结构
export function treeselectbyId(domainId) {
  return request({
    url: '/system/questiondomain/treeselect/'+ domainId,
    method: 'get'
  })
}

// 根据角色ID查询部门树结构
export function roleDomainTreeselect(roleId) {
  return request({
    url: '/system/questiondomain/roleDomainTreeselect/' + roleId,
    method: 'get'
  })
}

// 新增部门
export function addDomain(data) {
  return request({
    url: '/system/questiondomain',
    method: 'post',
    data: data
  })
}

export function addRootDomain(data) {
  return request({
    url: '/system/questiondomain/addRootDomain',
    method: 'post',
    data: data
  })
}



// 修改部门
export function updateDomain(data) {
  return request({
    url: '/system/questiondomain',
    method: 'put',
    data: data
  })
}

// 删除部门
export function delDomain(domainId) {
  return request({
    url: '/system/questiondomain/' + domainId,
    method: 'delete'
  })
}
